
// 封装求和函数，实现不定参数的求和
function add(...arr: number[]): number {
	return arr.reduce((p, n) => {
		return p + n
	}, 0)
}
const result1 = add(1, 2, 3)
const result2 = add(1, 2, 3, 4, 5)
const result3 = add(1, 2)

console.log(result1,result2,result3)


// 封装函数， 接受字符串类型的数组，返回数组的最长的字符串的信息
const arr:Array<string> = ['adc','fsd23','dfda1','1d','2rf342ds']

function maxLength(arr:Array<string>):string{
 arr.sort((a:string,b:string) => {
   return b.length - a.length
 })
 return arr[0]
}
console.log(maxLength(arr))



export {}
